package com.dao;

import com.utils.DBUtils;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.UUID;

@Repository
public class OrderDao {
    //生成订单
    public void createOrder(){
        String sql = "insert into t_order(orderNo) values(?)";
        Connection conn = null;

        try{
            conn = DBUtils.getConn();

            PreparedStatement stmt = conn.prepareStatement(sql);
            stmt.setString(1, UUID.randomUUID().toString());//生成32位随机字符串 不会重复
            stmt.executeUpdate();

        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
